        
             
        function selectLine(event, project_user_tables, project_id, user_id, time_id) {
	        event = event || window.event
	        var clicked_elem = event.target || event.srcElement
            var line = clicked_elem.parentNode
            var childs = line.childNodes
            var class_pattern = new RegExp('[a-zA-Z]*(?=Selected)')
            var del_space_pattern = new RegExp('[a-zA-Z]*')
            var user_table
            var time_table
            for(var i=0; i<childs.length; i++) {
                var line_element = childs[i]
                var line_element_class_name = (new String(line_element.className)).match(del_space_pattern)[0]
                if(!class_pattern.test(line_element_class_name)) {
                    line_element.className = line_element_class_name + 'Selected'
                }
                else {
                    line_element.className = line_element_class_name.match(class_pattern)[0]
                }
            }
            user_table = project_user_tables.searchTime(project_id, user_id)
            if(user_table.next_time!=null) {
                time_table = user_table.next_time
                time_table.changeSelectStateByTimeId(time_id)
            }
        }
        
        function printTime(project_user_tables, project_id, user_id, div_time_table) {
            var project_user_tables_temp
            var project_user_search_result
            var time_table
            var class_end
            var is_confirmed = 0
            time_table = ' '
            if(project_user_tables!=null) {
                project_user_search_result = project_user_tables.searchTime(project_id, user_id)
                if(project_user_search_result!=null)
                    is_confirmed = project_user_search_result.field_confirm
            }
            if((is_confirmed==1)&&(project_user_tables!=null)) {
                project_user_tables_temp = project_user_search_result.next_time
                while(project_user_tables_temp!=null) {
                    if(project_user_tables_temp.is_selected==0) 
                        class_end = ''
                    else 
                        class_end = 'Selected'
                    time_table+=    "<div class='TimeTableLine'>" + 
                                    "    <div onclick='selectLine(arguments[0], project_user_tables, " + project_id + ", " + user_id + ", " + project_user_tables_temp.time_id +")' class='TimeTableDate" + class_end + "'>" + 
                                            project_user_tables_temp.field_date + 
                                    "    </div>" + 
                                    "    <div onclick='selectLine(arguments[0], project_user_tables, " + project_id + ", " + user_id + ", " + project_user_tables_temp.time_id +")' class='TimeTableActivity" + class_end + "'>" + 
                                            project_user_tables_temp.field_activity + 
                                    "    </div>" + 
                                    "    <div onclick='selectLine(arguments[0], project_user_tables, " + project_id + ", " + user_id + ", " + project_user_tables_temp.time_id +")' class='TimeTableTime" + class_end + "'>" + 
                                            project_user_tables_temp.field_time + 
                                    "    </div>" + 
                                    "    <div onclick='selectLine(arguments[0], project_user_tables, " + project_id + ", " + user_id + ", " + project_user_tables_temp.time_id +")' class='TimeTableDetails" + class_end + "'>" + 
                                            project_user_tables_temp.field_details + 
                                    "    </div>" + 
                                    " </div>"
                    project_user_tables_temp = project_user_tables_temp.next_time
                }
                time_table+=    "<div class='TimeTableLine'>" + 
                                "    <div class='ConfirmButton'> <input onclick='"  + 'setSelectAll(project_user_tables, ' + project_id + ', ' + user_id + '), printTime(project_user_tables, ' + project_id + ", " + user_id + ', ' + '"' + div_time_table + '"' + ")' type='submit' value='Select All'> </div>" + 
                                "    <div class='ConfirmButton'> <input onclick='" + 'setSelectNone(project_user_tables, ' + project_id + ', ' + user_id + '), printTime(project_user_tables, ' + project_id + ", " + user_id + ', ' + '"' + div_time_table + '"' + ")' type='submit' value='Select None'> </div>" + 
                                "</div>" + 
                                "<div class='TimeTableLine'>" + 
                                "    <div class='ConfirmButton'> <input onclick='project_user_tables.joinSelectedWithTimeFieldNode(bottom_tables_confirm, " + user_id + ", user_select.name_field, " + project_id + ", project_select.name_field), mergeBottomTables(bottom_tables_confirm, bottom_tables_nonconfirm, " + '"div_bottom_tables"' + "), " + 'printTime(project_user_tables, ' + project_id + ", " + user_id + ', ' + '"' + div_time_table + '"' + ")' type='submit' value='Add to Confirm List'> </div>" + 
                                "    <div class='ConfirmButton'> <input onclick='project_user_tables.joinSelectedWithTimeFieldNode(bottom_tables_nonconfirm, " + user_id + ", user_select.name_field, " + project_id + ", project_select.name_field), mergeBottomTables(bottom_tables_confirm, bottom_tables_nonconfirm, " + '"div_bottom_tables"' + "), " + 'printTime(project_user_tables, ' + project_id + ", " + user_id + ', ' + '"' + div_time_table + '"' + ")' type='submit' value='Add to Non Confirm List'> </div>" + 
                                "</div>"
                document.getElementById(div_time_table).innerHTML = time_table
            }
            else
                document.getElementById(div_time_table).innerHTML = time_table
        }
        
        function createTimeBranches(t_details, t_user_id, t_project_id, t_date, t_type_activity, t_time, t_details, t_time_id) { 
            var time_table_next
            var time_table_temp
            time_table_next = this          
            if(t_details=='')
                t_details = 'no details'
            if(time_table_next.user_id==-1) {
                time_table_next.user_id = t_user_id
                time_table_next.project_id = t_project_id
                time_table_next.next_time = new TimeField(t_date, t_type_activity, t_time, t_details, t_time_id)
            }
            else {
                time_table_next = this
                while(time_table_next!=null) {
                    if((time_table_next.user_id==t_user_id)&&(time_table_next.project_id==t_project_id)) {
                        time_table_temp = new TimeField(t_date, t_type_activity, t_time, t_details, t_time_id)
                        time_table_temp.next_time = time_table_next.next_time
                        time_table_next.next_time = time_table_temp
                        break
                    }
                    time_table_temp = time_table_next
                    time_table_next = time_table_next.next_time_node
                }
                if(time_table_next==null) {
                    time_table_temp.next_time_node = new TimeFieldNode(t_user_id, t_project_id)
                    time_table_temp.next_time_node.next_time = new TimeField(t_date, t_type_activity, t_time, t_details, t_time_id)
                }
                time_table_next = this
            }
        }
        
        function TimeFieldNode(in_user_id, in_project_id) {
            this.user_id = in_user_id
            this.project_id = in_project_id
            this.next_time = null
            this.next_time_node = null
            
            this.createTimeBranches = createTimeBranches
        }
        
        
        function changeSelectStateByTimeId(time_id) {
            var time_field = this
            while(time_field!=null) {
                if(time_field.time_id==time_id) {
                    if(time_field.is_selected==0)
                        time_field.is_selected = 1
                    else
                        time_field.is_selected = 0
                    break
                }
                time_field = time_field.next_time
            }
        }
        
        function setSelectNone(project_user_tables, project_id, user_id) {
            var time_field = project_user_tables.searchTime(project_id, user_id).next_time
            while(time_field!=null) {
                time_field.is_selected = 0
                time_field = time_field.next_time
            }
        }
        
        function setSelectAll(project_user_tables, project_id, user_id) {
            var time_field = project_user_tables.searchTime(project_id, user_id).next_time
            while(time_field!=null) {
                time_field.is_selected = 1
                time_field = time_field.next_time
            }
        }
        
        function TimeField(in_field_date, in_field_activity, in_field_time, in_field_details, in_time_id) {
            this.time_id = in_time_id
            this.field_date = in_field_date
            this.field_activity = in_field_activity
            this.field_time = in_field_time
            this.field_details = in_field_details
            this.next_time = null
            this.is_selected = 0
            
            this.setSelectAll = setSelectAll
            this.setSelectNone = setSelectNone
            this.changeSelectStateByTimeId = changeSelectStateByTimeId
        }
        
        
        var time_table
        
        time_table = new TimeFieldNode(-1, -1)
